package com.zzx.day57Demo.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.zzx.day57Demo.Biz.ExpectBiz;
import com.zzx.day57Demo.model.Expect;


@Controller
@Scope("prototype")
@Namespace(value = "/Expect")
@Results({@Result(name = "list", location = "list.jsp"),
	@Result(name = "input", location = "add.jsp")})
public class ExpectAction extends BaseAction{
	
	private ExpectBiz expectBiz;
	private List<Expect>expList;
	private Expect exp;
	

	public Expect getExp() {
		return exp;
	}
	public void setExp(Expect exp) {
		this.exp = exp;
	}
	public List<Expect> getExpList() {
		return expList;
	}
	public void setExpList(List<Expect> expList) {
		this.expList = expList;
	}
	public void setExpectBiz(ExpectBiz expectBiz) {
		this.expectBiz = expectBiz;
	}
	
	
	@Action("list")
	public String list(){
		expList = expectBiz.findAll();
		System.out.println("expectList===="+expList.size());
		return "list";
	}
	@Action("add")
	public String add(){
		
		return "input";
	}
	@Action("save")
	public String save(){
		expectBiz.saveOrUpdate(exp);
		return list();
	}
	@Action("delete")
	public String delete(){
		expectBiz.delete(exp.getExpId());
		return "list";
	}
	@Action("update")
	public String update(){
		expectBiz.findById(exp.getExpId());
		return add();
	}

}
